from django.db import models
from apps.common.base.models import BaseModel
from apps.education.coursecate.models import Coursecate
import django.utils.timezone as timezone
from apps.education.teacher.models import Teacher
from apps.merchant.tag.models import Tag

class Course(BaseModel):

    teacher=models.ForeignKey(Teacher, related_name='teacher_course', verbose_name='教师', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    coursecate=models.ForeignKey(Coursecate, related_name='coursecate_course', verbose_name='课程分类', on_delete=models.SET_NULL, null=True, blank=True, db_constraint=False)
    tags = models.ManyToManyField(Tag, related_name='tags_course', blank=True, default=[], db_constraint=False)

    name = models.CharField("名称", max_length=200, blank=True, null=True, default='')
    coverUrl = models.CharField("封面", max_length=200, blank=True, default='')
    hour = models.IntegerField("课时", default=0)
    addr = models.CharField("地址", max_length=200, blank=True, default='')
    startTime = models.DateTimeField('开始时间', blank=True, default=timezone.now)
    endTime = models.DateTimeField('结束时间', blank=True, default=timezone.now)
    lastTime = models.DateTimeField('报名截止时间', blank=True, default=timezone.now)
    intrRichText = models.TextField("课程介绍", max_length=20000, blank=True, default='')
    status = models.IntegerField("状态", blank=True, null=True, default=1)  # 1：草稿 2: 已发布

    class Meta:
        verbose_name = 'Course'
        verbose_name_plural = verbose_name
